<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="cfn" uri="http://com.abou/cfn"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/fn"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>

<%-- Creates a form select or list or radio buttons list or check boxes list. Parameters are :
    - code : the label code for the input
    - path : the path for the input
    - valuesVarName : the name of the request scoped variable storing the possible values.
    - id : optional, the ID for the component enclosing the form element(s).
    - mandatory : optional, boolean string value, 'true' if the field is mandatory.
    - onchange : optional, the javascript to execute when the value is modified.
    - fixedWidth : optional, only for the boxes case. A boolean value used to specify if
                      the radio buttons or the check boxes width should be the same for
                      all of them. By default : false.
    - modifCheck : optional, boolean string value, 'true' to activate the support for the
        form submit button state dynamic check : the submit button is enabled only if changes
        occured on the form.
--%>

<%-- Computing the javascript code to use when the value changes, so
  that the form submit button state is modified --%>
<c:if test="${param.modifCheck == 'true' ? true : false}">
  <c:set var="modifCheckJs" value="checkModified(this);"/>
</c:if>

<%-- The header --%>
<jsp:include page="../form/form-field-header.jsp">
  <jsp:param name="code" value="${param.code}"/>
  <jsp:param name="mandatory" value="${param.mandatory}"/>
</jsp:include>

<%-- Displaying the form field
<div id="${param.id}" class="color">--%>

<div class="row">
<label class="info">&nbsp;</label>

<ul class="color">

	  <c:forEach items="${requestScope[param.valuesVarName]}" var="curItem" varStatus="stat">

	    <li><span class="lgd" style="background-color:${curItem.colorCodeHtml};">&nbsp;</span>
	      <%-- Checking whether the box should be disabled --%>
	      <c:set var="curVal" value="${curItem};"/>
	      <c:set var="disabled" value="${not empty disabledValues &&
	          fn:contains(disabledValues, curVal)}"/>
	      <%-- The box --%>
	      <form:checkbox label="${cfn:formatExt(pageContext, curItem, true)}"
	        path="${param.path}" value="${curItem}" cssErrorClass="error ${disabled ? 'disabled' : ''}"
	        onchange="${modifCheckJs}${param.onchange}" onclick="${modifCheckJs}${param.onchange}"
	        cssClass="${stat.first ? param.focused : ''} ${disabled ? 'disabled' : ''}"
	        disabled="${disabled}"/>
	     </li>

	  </c:forEach>
</ul>

<%-- Displaying the form field error message --%>
<jsp:include page="../form/form-field-errors.jsp">
  <jsp:param name="path" value="${param.path}"/>
</jsp:include>

<%-- The row footer --%>
<jsp:include page="../form/form-field-footer.jsp">
  <jsp:param name="warningCodes" value="${param.warningCodes}"/>
  <jsp:param name="showWarning" value="${param.showWarning}"/>
</jsp:include>
</div>